package com.acwing.partition12;

import java.io.*;
import java.util.Arrays;

/**
 * @author `RKC`
 * @date 2022/2/10 10:19
 */
public class AC1192奖金_差分约束_拓扑排序 {

    private static final int N = 10010, M = 20010;
    private static int[] head = new int[N], ver = new int[M], next = new int[M], din = new int[N];
    private static int[] q = new int[N], dist = new int[N];

    private static int n = 0, m = 0, idx = 0, qh = 0, qt = -1;

    private static final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    private static final BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));

    public static void main(String[] args) throws IOException {
        String[] ss = reader.readLine().split(" ");
        n = Integer.parseInt(ss[0]);
        m = Integer.parseInt(ss[1]);
        Arrays.fill(head, -1);
        for (int i = 0; i < m; i++) {
            ss = reader.readLine().split(" ");
            int a = Integer.parseInt(ss[0]), b = Integer.parseInt(ss[1]);
            add(b, a);
            din[a]++;
        }
        //拓扑排序判断是否有环
        if (!topsort()) writer.write("Poor Xed\n");
        else {
            //根据拓扑序列求最长路
            for (int i = 1; i <= n; i++) dist[i] = 100;
            for (int i = 0; i < n; i++) {
                int u = q[i];
                for (int j = head[u]; j != -1; j = next[j]) {
                    int v = ver[j];
                    dist[v] = Math.max(dist[v], dist[u] + 1);
                }
            }
            int sum = 0;
            for (int i = 1; i <= n; i++) sum += dist[i];
            writer.write(sum + "\n");
        }
        writer.flush();
    }

    private static boolean topsort() {
        for (int i = 1; i <= n; i++) {
            if (din[i] == 0) q[++qt] = i;
        }
        while (qh <= qt) {
            int u = q[qh++];
            for (int i = head[u]; i != -1; i = next[i]) {
                int v = ver[i];
                if (--din[v] == 0) q[++qt] = v;
            }
        }
        return qt == n - 1;
    }

    private static void add(int a, int b) {
        ver[idx] = b;
        next[idx] = head[a];
        head[a] = idx++;
    }
}
